-- bootstrap lazy.nvim, LazyVim and your plugins
require("config.lazy")
require("config.markdown")
require("config.default")
-- 开启 Folding 模块
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "nvim_treesitter#foldexpr()"
vim.opt.relativenumber = true
-- 默认不要折叠
-- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file
vim.opt.foldlevel = 99
vim.cmd([[
  augroup _fold_bug_solution  " https://github.com/nvim-telescope/telescope.nvim/issues/559
    autocmd!
    autocmd BufRead * autocmd BufWinEnter * ++once normal! zx
  augroup end
]])
local showLineNumber = function()
  local line = vim.api.nvim_get_current_line()
  local pattern = " ([^:]+):(%d+):(%d+)"
  local filepath, line_nu, col_nu = string.match(line, pattern)
  if filepath and line_nu and col_nu then
    vim.cmd("e" .. filepath)
    vim.api.nvim_win_set_cursor(0, { tonumber(line_nu), tonumber(col_nu) })
  end
  print(filepath, line_nu, col_nu)
end

vim.api.nvim_create_autocmd("BufEnter", {
  callback = function()
    vim.keymap.set("n", "pk", showLineNumber, { silent = true, noremap = true, buffer = true })
  end,
})
